package com.runa.monitor.platinterface.mqtt.vo;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
public class FourGTempPressureVO extends FourGVO {
    private String id;
    private String typ;
    private String nbattach1;
    private String rxw;
    private String nbdly;
    private String rep;
    private String cprd;
    private String rrem;
    private String csq;
    private String icc;
    private String imei;
    private String rsrp;
    private String snr;
    private String t1;
    private String t2;
    private String p1;
    private String p2;
    private String sta;
    private String ver;
    private String rtc;
    private String sitv1;
    private String uitv1;
    private String sitv2;
    private String uitv2;
    private String hot;
    private String bat;
    private String life;
    private String reset;
    private String compile;

    public static void main(String[] args) {
        String s = "rtc:20250411151430,T1:[22.4],T2:[99.9],P1:[9.999],P2:[9.999],";
        FourGTempPressureVO gene = FourGTempPressureVO.gene(s);
        System.out.println(JSON.toJSONString(gene));
    }

    @SneakyThrows
    public static FourGTempPressureVO gene(String json) {
        return generate(FourGTempPressureVO.class, json);
    }


    public String wakeUpCycle(boolean heatingPeriod) {
        return heatingPeriod ? uitv1 : uitv2;
    }


    public Integer acquisitionCycle(boolean heatingPeriod) {
        if (heatingPeriod) {
            if (null == sitv1) {
                return null;
            } else {
                return Integer.valueOf(sitv1);
            }
        } else {
            if (null == sitv2) {
                return null;
            } else {
                return Integer.valueOf(sitv2);
            }

        }
    }
}
